package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.BannerDO;
import com.starlink.model.request.BannerRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface BannerMapper extends BaseMapper<BannerDO> {
    BannerDO selectDOById(Long id);
    List<BannerDO> selectDOList(BannerDO banner);
    int insertDO(BannerDO banner);
    int batchInsertDO(List<BannerDO> bannerDOList);
    int updateDO(BannerDO banner);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from banner",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") BannerRequest param);

    List<BannerDO> pageQuery(BannerRequest param);
}
